{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "26a633f2",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "badf0a2e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1628736398.4724174"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.time()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "e31c8cfb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1628736447.9435935"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.time()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "d2c89883",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1628736458.7841198"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.time()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "c3389f61",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1628736463.0715332"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.time()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "6775571a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1628736464.2078395"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.time()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "857ea38a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1628736465.4627876"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.time()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "c91e4fcb",
   "metadata": {},
   "outputs": [],
   "source": [
    "now = int(time.time())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "ee06ca80",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1628736536"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "now"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "ab269a47",
   "metadata": {},
   "outputs": [],
   "source": [
    "timeArray = time.localtime(now)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "a19409dc",
   "metadata": {},
   "outputs": [],
   "source": [
    "other = time.strftime(\"%Y-%m-%d %H:%M:%S\", timeArray)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "9ae9c8ac",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'2021-08-12 10:48:56'"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "other"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "0209f7d8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'2021+08+12 10:48:56'"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.strftime(\"%Y+%m+%d %H:%M:%S\", timeArray)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "b97a590d",
   "metadata": {},
   "outputs": [],
   "source": [
    "time1 = time.strptime(other, '%Y-%m-%d %H:%M:%S')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "f1c7e0a6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2021, tm_mon=8, tm_mday=12, tm_hour=10, tm_min=48, tm_sec=56, tm_wday=3, tm_yday=224, tm_isdst=-1)"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "5239c73b",
   "metadata": {},
   "outputs": [],
   "source": [
    "timestamp = int(time.mktime(time1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "adca2ebe",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1628736536"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "timestamp"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "b779861c",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time\n",
    "import datetime"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "84cc8696",
   "metadata": {},
   "source": [
    "t1 = '2020-02-24 16:08:02'\n",
    "t2 = '2021-08-12 11:05:00'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "4a30daad",
   "metadata": {},
   "outputs": [],
   "source": [
    "t1 = '2020-02-24 16:08:02'\n",
    "t2 = '2021-08-12 11:05:00'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "c4b7f881",
   "metadata": {},
   "outputs": [],
   "source": [
    "d1 = datetime.datetime.strptime(t1,'%Y-%m-%d %H:%M:%S')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "83851091",
   "metadata": {},
   "outputs": [],
   "source": [
    "d2 = datetime.datetime.strptime(t2,'%Y-%m-%d %H:%M:%S')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "c0f808a1",
   "metadata": {},
   "outputs": [],
   "source": [
    "delta = d2 - d1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "1b26593e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.timedelta(days=534, seconds=68218)"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "delta"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "cb297d20",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "534"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "delta.days"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "700803a4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "68218"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "delta.seconds"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6703d8b2",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
